package is.ru.honn.rumblr.domain;

import is.ru.honn.rumblr.util.XmlUtil;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

public abstract class AbstractRumblrPost implements RumblrPost
{
  protected String id;
  protected String url;
  protected Date dateGmt;
  protected String type;
  protected List<String> tags = new ArrayList<String>();

  public String getId()
  {
    return id;
  }

  public void setId(String id)
  {
    this.id = id;
  }

  public String getUrl()
  {
    return url;
  }

  public void setUrl(String url)
  {
    this.url = url;
  }

  public Date getDateGmt()
  {
    return dateGmt;
  }

  public void setDateGmt(Date dateGmt)
  {
    this.dateGmt = dateGmt;
  }

  public String getType()
  {
    return type;
  }

  public void setType(String type)
  {
    this.type = type;
  }

  public void addTag(String tag)
  {
    tags.add(tag);
  }

  public List getTags()
  {
    return tags;
  }

  public void addTags(List<String> tags)
  {
    this.tags.addAll(tags);
  }

  protected String header()
  {
    return "id: " + id + " " + XmlUtil.DATE_FORMAT.format(dateGmt) + " " + url + "\n";
  }

  protected String tags()
  {
    StringBuffer tagString = new StringBuffer();
    tagString.append("Tags: ");
    for(String tag : tags)
    {
      tagString.append("#" + tag + " ");
    }
    return tagString.toString();
  }
}
